package com.example.gpstest.DataBean;

import android.content.Context;
import android.content.SharedPreferences.Editor;

public class GPSSharedPreference {
    private static final String PREFERENCE_NAME = "gps_params_pref";

    public static void setPreference(Context context, String key, int value) {
        Editor editor = context.getSharedPreferences(PREFERENCE_NAME, 0).edit();
        editor.putInt(key, value);
        editor.commit();
    }

    public static void setPreference(Context context, String key, Boolean value) {
        Editor editor = context.getSharedPreferences(PREFERENCE_NAME, 0).edit();
        editor.putBoolean(key, value.booleanValue());
        editor.commit();
    }

    public static void setPreference(Context context, String key, String value) {
        Editor editor = context.getSharedPreferences(PREFERENCE_NAME, 0).edit();
        editor.putString(key, value);
        editor.commit();
    }

    public static int getPreference(Context context, String key, int defValue) {
        return context.getSharedPreferences(PREFERENCE_NAME, 0).getInt(key, defValue);
    }

    public static boolean getPreference(Context context, String key, Boolean defValue) {
        return context.getSharedPreferences(PREFERENCE_NAME, 0).getBoolean(key, defValue.booleanValue());
    }

    public static String getPreference(Context context, String key, String defValue) {
        return context.getSharedPreferences(PREFERENCE_NAME, 0).getString(key, defValue);
    }
}

